package com.cpkso.buss.backend.trade.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cpkso.buss.backend.trade.service.TbOrderService;
import com.cpkso.buss.backend.trade.vo.TbSBOrderVo;
import com.runze.base.web.BaseController;
import com.runze.base.web.Response;

/**
 * 用于接收并合并订单
 * @author wrzhxy@qq.com
 * @date 2018年4月7日
 * 
 * 需要判断 如果订单号已经存在就不添加到数据库
 */
@RestController
@RequestMapping("/order")
public class MergeOrderController extends BaseController {
	// TODO 接收卖家订单信息，添加新订单
	@PostMapping("/s")
	public Response receiveSellerOrder(@RequestBody List<TbSBOrderVo> tbSBOrderVo) {
		tbOrderService.createTbSellerOrder(tbSBOrderVo);
		return success();
	}
	// TODO 接收买家订单信息，添加新订单
	@PostMapping("/b")
	public Response receiveBuyerOrder(@RequestBody List<TbSBOrderVo> tbSBOrderVo) {
		tbOrderService.createTbBuyerOrder(tbSBOrderVo);
		return success();
	}
	@PutMapping("/merge")
	public Response mergeOrder() {
		tbOrderService.mergeOrder();
		return success();
	}
	
	@Autowired
	private TbOrderService tbOrderService;
}
